<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/6/15
 * Time: 16:58
 */

namespace common\component;


class Email
{
    //定义邮件参数
    public $usermail;   //用户邮箱
    public $subject;    //邮件主题
    public $content;    //邮件内容
    public $templet;    //邮件模板
    public $param;      //参数变量

    //接收邮件方法
    public function send()
    {
        if(!empty($this->templet)){
            $mail = \Yii::$app->mailer->compose($this->templet,$this->param)
//                ->setFrom('support@manbfx.com')
                ->setTo($this->usermail)
                ->setSubject($this->subject)
                ->send();

        }else{
            $mail = \Yii::$app->mailer->compose()
//                ->setFrom('support@manbfx.com')
                ->setTo($this->usermail)
                ->setSubject($this->subject)
                ->setTextBody($this->content)
                ->send();
        }
        if($mail){
            return true;
        }else{
            return false;
        }
    }
}

